package com.wm.walmart.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import com.wm.walmart.entity.UserRole;
import com.wm.walmart.service.IUserRoleService;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author xieyize
 * @since 2019-12-09
 */
@RestController
@RequestMapping("/userRole/")
public class UserRoleController {
	@Resource
	private IUserRoleService userRoleService;

	/**
	 * 添加用户角色 http://localhost:8080/walmart/userRole/insertUserRole?uId=7&rId=1
	 */
	@RequestMapping("insertUserRole")
	public Object insertUserRole(UserRole userRole) {
		return userRoleService.save(userRole);
	}

	/**
	 * 根据用户角色id修改用户角色
	 * http://localhost:8080/walmart/userRole/updateUserRole?urId=9&uId=7&rId=2
	 */
	@RequestMapping("updateUserRole")
	public Object updateUserRole(UserRole userRole) {
		return userRoleService.updateById(userRole);
	}

	/**
	 * 根据用户角色id修改用户角色
	 * http://localhost:8080/walmart/userRole/deleteUserRoleByUrId?urId=9
	 */
	@RequestMapping("deleteUserRoleByUrId")
	public Object deleteUserRoleByUrId(Integer urId) {
		return userRoleService.removeById(urId);
	}
}
